# -*- coding: UTF-8 -*-
import urllib
import urllib2
import json
import time

url="http://www.zhihu.com/login/phone_num"
username="15057126798"
password="YANGHUI123"

#请求参数
requestParamter={}
requestParamter['phone_num']=username
requestParamter['password']=password
requestParamter['remember_me']='true'
#print requestParamter

#请求头信息
requestHeader={}
requestHeader['Accept-Language']='zh-CN,zh;q=0.8'
requestHeader['User-Agent']='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36")'
requestHeader['X-Requested-With']='XMLHttpRequest'
#print requestHeader

request=urllib2.Request(url)
response=urllib2.urlopen(request, urllib.urlencode(requestParamter))
doc=response.read()
print doc
decodejson=json.loads(doc)
#print decodejson.keys()
errcode=decodejson['errcode']

if errcode>0 :
    print "登录失败"
else:
    print "登录成功"

t=str(int(time.time()*1000))
zhihuCaptcha="http://www.zhihu.com/captcha.gif?r=" + t + "&type=login"






        
    
